import updateManager from './common/updateManager';
import {
  postForm
} from './utils/request'


App({
  onLaunch: function () {
    this.globalData = {
      // basePath: 'http://192.168.110.86:8080',
      basePath: 'https://www.nutripai.com',
      hasLogin: false,
    };
    let _this = this;
    wx.login({
      timeout: 10000,
      success: function (res) {
        let code = res.code;
        postForm({
          url: 'front/api/account/login',
          data: {
            code: code
          }
        }).then(user => {
          wx.setStorageSync('userId', user.id);
          wx.setStorageSync('user', user);
          wx.setStorageSync('mobile', user.mobile || '')
          _this.globalData.hasLogin = true;
        })
      }
    })
  },
  onShow: function () {
    updateManager();
  },
});